package com.df.ez_game.server.logic.status_sync;

import com.df.ez_game.server.UserSession;
import com.df.ez_game.server.logic.ISessionLifecycle;
import com.df.ez_game.server.logic.status_sync.controllers.SyncController;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class SyncSessionLifecycle implements ISessionLifecycle {
    @Override
    public void onActive(ChannelHandlerContext ctx, UserSession session) {
      log.info("新连接："+session.getChannel().id());
    }

    @Override
    public void onException(ChannelHandlerContext ctx, Throwable cause, UserSession session) {

    }

    @Override
    public void onLogin(Channel channel, UserSession session, Long loginId) {

    }

    @Override
    public void onLoginOut(Channel channel, UserSession session) {
        SyncController.users.remove(session.getUserId());
        log.info("用户断开："+session.getUserId());
    }

    @Override
    public void onInactive(ChannelHandlerContext ctx, UserSession session) {
        log.info("连接断开："+session.getChannel().id());
    }
}
